package com.scc.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.scc.entity.Questions;

public interface QuestionsMapper {
	/**
	 * 查询全部,时间降序
	 * @return
	 */
	@Select("select * from questions order by lastModified desc")
	List<Questions> selAll();
	
	/**
	 * 根据id查询
	 * @param id
	 * @return
	 */
	@Select("select * from questions where id=#{0}")
	Questions selById(long id);
	
	/**
	 * 新增
	 * @param ques
	 * @return
	 */
	@Insert("insert into questions values(default,#{title},#{detailDesc},0,now())")
	int insQuestion(Questions ques);
	
	/**
	 * 更新,回答次数+1,最后修改时间
	 * @param id
	 * @return
	 */
	@Update("update questions set answerCount=answerCount+1,lastModified=now() where id=#{0}")
	int updQuestion(long id);
	
}
